<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@page import="com.usernet.product.tools.UsersRight"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>

		<link rel="stylesheet" type="text/css" href="resources/css/style.css">
		<script src="resources/js/comm.js"></script>
		<script type="text/javascript">
			function checkForm(){
				var loginName = $("loginName").value;
				var niceName = $("niceName").value;
				var password1 = $("password1").value;
				var password2 = $("password2").value;
				var email = $("email").value;
				var status = $("status").value;
				var tel = $("tel").value;
				if(loginName == ""){
					alert("登录名不能为空");
				}else if(niceName == ""){
					alert("昵称不能为空");
				}else if(tel == ""){
					alert("手机号码不能为空");
				}else if(!checkPhone(tel)){
					alert("手机号码格式不正确");
				}else if(password1 == ""){
					alert("密码不能为空");
				}else if(password1.length<6){
					alert("密码不能少于6位");
				}else if(password2 != password1){
					alert("两次密码不一致");
				}else if(email == ""){
					alert("email不能为空");
				}else if(!checkEmail(email)){
					alert("email格式错误");
				}else if(status == -1){
					alert("请选择角色");
				}else{
					loading();
					submitForm("addform");
				}
			}
		</script>

	</head>

	<body onkeydown="if(event.keyCode==27) return false;">
		<jsp:include page="../inc/header.jsp"></jsp:include>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="30" background="resources/images/other/tab_05.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="resources/images/other/tab_03.gif" width="12"
									height="30" />
							</td>
							<td>
								<div class="page_title">
									<img align="middle" src="resources/images/other/tb.gif"
										width="16" height="16" />
									修改用户
								</div>
							</td>
							<td>
								<div class="button_bar">
									<input value="返回" type="button" class="common_button"
										onclick="javascript:history.go(-1);loading();">
									<input value="保存" type="button" class="common_button" onclick="checkForm();">
									<input value="刷新" type="button" class="common_button"
										onclick="location='user.do?method=toUpdate&id=${user.id}';loading();">
								</div>
							</td>
							<td width="16" height="30">
								<img src="resources/images/other/tab_07.gif" width="16"
									height="30" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="8" background="resources/images/other/tab_12.gif">
							</td>
							<td>
								<form action="user.do" method="post" id="addform">
									<input type="hidden" name="method" value="doUpdate">
									<input type="hidden" name="id" value="${admin.id }">
									<table cellspacing="1" cellpadding="0" class="query_form_table">
										<tr>
											<th>
												登录名
											</th>
											<td>
												${admin.loginName }
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th>
												昵称
											</th>
											<td>
												<input class="comm_input" name="niceName" id="niceName" value="${user.niceName }" maxlength="50"/>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th>
												手机号码
											</th>
											<td>
												<input class="comm_input" name="tel" id="tel" value="${user.tel }" maxlength="12"/>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th>
												密码
											</th>
											<td>
												<input class="comm_input" name="password1" id="password1" type="password" maxlength="20"/>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th>
												确认密码
											</th>
											<td>
												<input class="comm_input" id="password2"  type="password" maxlength="20"/>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th>
												邮箱
											</th>
											<td>
												<input class="comm_input" id="email" value="${admin.email }" name="email" maxlength="50"/>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th>
												角色
											</th>
											<td>
												<select class="comm_input" name="flag" id="status">
													<option value="-1">--请选择--</option>
													<option <logic:equal value="<%=String.valueOf(UsersRight.comm) %>" name="user" property="flag">selected</logic:equal> value="0">--普通用户--</option>
													<option <logic:equal value="<%=String.valueOf(UsersRight.developer) %>" name="user" property="flag">selected</logic:equal> value="<%=UsersRight.developer %>">--开发者--</option>
												</select>
												<span class="red_star">*</span>
											</td>
										</tr>
									</table>
								</form>
							</td>
							<td width="8" background="resources/images/other/tab_15.gif">
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td height="35" background="resources/images/other/tab_19.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="resources/images/other/tab_18.gif" width="12"
									height="35" />
							</td>
							<td>
								&nbsp;
							</td>
							<td width="16">
								<img src="resources/images/other/tab_20.gif" width="16"
									height="35" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>
<jsp:include page="../inc/footer.jsp"></jsp:include>